/* GUI CONVERTED from eciq13.p (converter v1.76) Wed May 28 02:21:15 2003 */
/* eciq13.p - ECN PRODUCT STRUCTURE INQUIRY                             */
/* Copyright 1986-2003 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.8.1.5 $                                                         */
/*V8:ConvertMode=Report                                                 */
/* REVISION: 7.4      LAST MODIFIED: 04/20/94   BY: qzl *H358*          */
/* REVISION: 7.4      LAST MODIFIED: 12/01/94   BY: qzl *H612*          */
/* REVISION: 7.4      LAST MODIFIED: 04/06/95   BY: ame *H0CF*          */
/*                                   04/24/95   by: srk *H0C4*          */
/* REVISION: 7.4      LAST MODIFIED: 11/15/94   BY: qzl *H0J1*          */
/* REVISION: 7.4      LAST MODIFIED: 10/08/96   BY: *H0N2*  Russ Witt       */
/* REVISION: 8.6      LAST MODIFIED: 06/18/97   BY: Joe Gawel    *K0F6* */
/* REVISION: 8.6      LAST MODIFIED: 08/13/97   BY: Joe Gawel    *K0H5* */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan       */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/14/00 BY: *N0KW* Jacolyn Neder      */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.8.1.5 $    BY: K Paneesh             DATE: 05/27/03  ECO: *P0T5*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdeclre.i}
{pxmaint.i}

{pxphdef.i pspl}

{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/*PLACED CONTENTS OF ECMTPARM.I IN HERE*/
define input parameter ecm_recid as recid.
define input parameter prog_type as character.
define input parameter inq_yn    as logical.
define input parameter dmpld    like mfc_logical.
define input parameter mstrfile like mfc_logical.
define output parameter msgnbr  like msg_nbr initial 0.
define output parameter warnlvl as integer initial 0.

define variable ecd1par    like ecd1_par no-undo.
define variable ecd1comp   like ecd1_comp no-undo.
define variable ecd1ref    like ecd1_ref no-undo.
define variable par_desc   like pt_desc1.
define variable comp_desc  like pt_desc1.
define variable l-um       like pt_um no-undo.
define variable psmand     like ps_mandatory.
define variable psdflt     like ps_default.
define variable ecdcmmts   like mfc_logical initial no label "Comments".
define variable true1      like mfc_logical initial yes.
define variable false1     like mfc_logical initial no.
define variable bombatch   like bom_batch.
define variable bombatchum like bom_batch_um.
define variable ecd1qad01  like ecd1__qad01.

define shared workfile ecmmstr like ecm_mstr.
define shared workfile ecd1det like ecd1_det.
define shared workfile qadwkfl like qad_wkfl.
define shared workfile cmtdet  like cmt_det.
define shared variable error_msg as character format "x(60)" extent 10.

do for ecmmstr,ecd1det,cmtdet,qadwkfl:

   /* DISPLAY SELECTION FORM */
   FORM /*GUI*/ 
      {ecform06.i}
   with STREAM-IO /*GUI*/  frame form06 width 80 side-labels.

   /* SET EXTERNAL LABELS */
   setFrameLabels(frame form06:handle).

   find first ecmmstr
      where recid(ecmmstr) = ecm_recid
      no-lock no-error.
   if not available (ecmmstr)
   then
      return.

   find first ecd1det
      where ecd1_nbr = ecm_nbr
      no-error.
   if available ecd1det
   then
      page.

   for each ecd1det
      where ecd1_nbr = ecm_nbr
      no-lock with frame form06:
      assign
         par_desc = ""
         comp_desc = "".

      find bom_mstr
         where bom_par = ecd1_par
         no-lock no-error.
      if available bom_mstr
         and bom_desc <> ""
      then
         par_desc = bom_desc.
      else do: /* IF AVAILABLE bom_mstr */

         find pt_mstr
            where pt_part = ecd1_par
            no-lock no-error.
         if available pt_mstr
         then
            par_desc = pt_desc1.
      end. /* ELSE DO: */

      /* GET THE COMPONENT UM AND DESCRIPTION */
      {pxrun.i &PROC = 'get_um_desc_data'
               &PROGRAM = 'pspl.p'
               &HANDLE  = ph_pspl
               &PARAM   = "(
                            input  ecd1_comp,
                            output l-um,
                            output comp_desc
                           )"
      }

      display
         ecd1_par @ ecd1par
         par_desc
         ecd1_comp @ ecd1comp
         comp_desc
         ecd1_ref  @ ecd1ref
         ecd1__qad01 @ ecd1qad01
         ecd1_qty_per_b
         l-um @ pt_um
         ecd1_scrp_pct
         ecd1_qty_type
         ecd1_batch_pct
         ecd1_op
         ecd1_item_no
         ecd1__qad03
         false1 when(ecd1__qad04 = "0") @ psmand
         true1  when(ecd1__qad04 <> "0") @ psmand
         false1 when(ecd1__qad05 = "0") @ psdflt
         true1  when(ecd1__qad05 <> "0") @ psdflt
         ecd1_rmks
         true1  when(ecd1_cmtindx <> 0) @ ecdcmmts
         false1 when(ecd1_cmtindx = 0) @ ecdcmmts
         ecd1_lt_off
         ecd1_fcst_pct
         ecd1_group
         ecd1_psprocess
      with frame form06 STREAM-IO /*GUI*/ .

      if not dmpld
      then do:
         if not mstrfile
         then
            put error_msg[6].
         else
         if can-find(ecd1_det where
            ecd1_det.ecd1_nbr = ecd1det.ecd1_nbr and
            ecd1_det.ecd1_par = ecd1det.ecd1_par and
            ecd1_det.ecd1_comp = ecd1det.ecd1_comp and
            ecd1_det.ecd1_ref = ecd1det.ecd1_ref) then put error_msg[1].

         else
         if (not can-find(pt_mstr where pt_part = ecd1det.ecd1_par)
            and not can-find(bom_mstr where bom_par = ecd1det.ecd1_par))
            or (not can-find(pt_mstr where pt_part = ecd1det.ecd1_comp)
            and not can-find(bom_mstr where bom_par = ecd1det.ecd1_comp))
         then
            put error_msg[3].
      end. /* IF NOT dmpld */
      down.

      if ecd1_cmtindx <> 0 then do:
         for each cmtdet no-lock
            where cmt_indx = ecd1_cmtindx
            with frame ecdc attr-space side-labels width 80 row 10  overlay:
            FORM /*GUI*/  cmt_seq skip
               cmt_cmmt[1] no-label
               cmt_cmmt[2] no-label
               cmt_cmmt[3] no-label
               cmt_cmmt[4] no-label
               cmt_cmmt[5] no-label
               cmt_cmmt[6] no-label
               cmt_cmmt[7] no-label
               cmt_cmmt[8] no-label
            with STREAM-IO /*GUI*/  frame ecdc width 80.

            /* SET EXTERNAL LABELS */
            setFrameLabels(frame ecdc:handle).
            display cmt_seq + 1 @ cmt_seq
               cmt_cmmt[1 for 8] no-label with frame ecdc STREAM-IO /*GUI*/ .
            down.

            if cmt_cmmt[9] + cmt_cmmt[10] + cmt_cmmt[11] + cmt_cmmt[12]
               + cmt_cmmt[13] + cmt_cmmt[14] + cmt_cmmt[15] <> ""
            then do with frame ecdc:
               display cmt_seq + 1 @ cmt_seq
                  cmt_cmmt[9]  @ cmt_cmmt[1]
                  cmt_cmmt[10] @ cmt_cmmt[2]
                  cmt_cmmt[11] @ cmt_cmmt[3]
                  cmt_cmmt[12] @ cmt_cmmt[4]
                  cmt_cmmt[13] @ cmt_cmmt[5]
                  cmt_cmmt[14] @ cmt_cmmt[6]
                  cmt_cmmt[15] @ cmt_cmmt[7]
               with frame ecdc STREAM-IO /*GUI*/ .
               down.
            end. /* IF cmt_cmmt[9]... */

            if not dmpld
            then
               if not mstrfile
               then
                  put error_msg[5].

            down.
            
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/

         end. /* FOR EACH cmtdet */
         hide frame ecdc.
      end. /* IF ecd1_cmtindx <> 0 then do: */
      
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/

   end. /* FOR EACH ecd1det */
end. /* DO FOR ecmmstr,... */
